<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <script src="./lib/esl.js"></script>
    <script src="./lib/config.js"></script>
    <script src="./lib/facePrint.js"></script>
    <script src="lib/testHelper.js"></script>
    <link rel="stylesheet" href="lib/reset.css"/>
</head>
<body>
<style>
    h1 {
        line-height: 60px;
        height: 60px;
        background: #ddd;
        text-align: center;
        font-weight: bold;
        font-size: 14px;
    }

    .chart {
        height: 500px;
    }
</style>

<script>
    function makeToggleChartButtons(toggleClip) {
        return [{
            text: 'Set Clip',
            onclick: function () {
                toggleClip(true);
            }
        }, {
            text: 'Set Visible',
            onclick: function () {
                toggleClip(false);
            }
        }];
    }
</script>

<div class="chart" id="scatter-clip-cartesian"></div>
<script>
    require([
        'echarts'
    ], function (echarts) {
        var option = {
            xAxis: {},
            yAxis: {
                min: 5,
                max: 10
            },
            series: [{
                symbolSize: 20,
                data: [
                    [10.0, 8.04],
                    [8.0, 6.95],
                    [13.0, 7.58],
                    [9.0, 8.81],
                    [11.0, 8.33],
                    [14.0, 9.96],
                    [6.0, 7.24],
                    [4.0, 4.26],
                    [12.0, 10.84],
                    [7.0, 4.82],
                    [5.0, 5.68]
                ],
                type: 'scatter'
            }]
        };
        var chart = testHelper.create(echarts, 'scatter-clip-cartesian', {
            title: 'Scatter Clip on Cartesian',
            option: option,
            height: 400,
            buttons: makeToggleChartButtons(function (clip) {
                chart.setOption({
                    series: [{
                        clip: clip
                    }]
                })
            })
        });
    })
</script>


<div class="chart" id="scatter-clip-polar"></div>
<script>
    require([
        'echarts'
    ], function (echarts) {
        var data1 = [];

        for (var i = 0; i < 100; i++) {
            data1.push([Math.random() * 10, Math.random() * 360]);
        }

        var option = {
            polar: {},
            angleAxis: {
                type: 'value',
                min: 50,
                max: 180
            },
            radiusAxis: {
                axisAngle: 0,
                min: 0,
                max: 5
            },
            series: [{
                coordinateSystem: 'polar',
                name: 'scatter',
                type: 'scatter',
                symbolSize: 10,
                data: data1
            }]
        };
        var chart = testHelper.create(echarts, 'scatter-clip-polar', {
            title: 'Scatter Clip on Polar',
            option: option,
            height: 400,
            buttons: makeToggleChartButtons(function (clip) {
                chart.setOption({
                    series: [{
                        clip: clip
                    }]
                })
            })
        });
    })
</script>


<div class="chart" id="large-scatter-clip"></div>
<script>
    require([
        'echarts'
    ], function (echarts) {
        // Standard Normal variate using Box-Muller transform.
        function rand() {
            var u = 0, v = 0;
            while (u === 0) u = Math.random(); //Converting [0,1) to (0,1)
            while (v === 0) v = Math.random();
            return Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
        }

        var data = [];

        for (let i = 0; i < 1e4; i++) {
            data.push([
                rand(),
                rand()
            ]);
        }
        var option = {
            xAxis: {
                type: 'value',
                min: -2,
                max: 2
            },
            yAxis: {
                type: 'value',
                min: -2,
                max: 2
            },
            series: [{
                symbolSize: 2,
                large: true,
                data: data,
                symbol: 'rect',
                type: 'scatter'
            }]
        };
        var chart = testHelper.create(echarts, 'large-scatter-clip', {
            title: 'Large Scatter Clip',
            option: option,
            height: 400,
            buttons: makeToggleChartButtons(function (clip) {
                chart.setOption({
                    series: [{
                        clip: clip
                    }]
                })
            }).concat([{
                text: 'Set Large',
                onclick: function () {
                    chart.setOption({
                        series: [{
                            large: true,
                            progressive: 0
                        }]
                    })
                }
            }, {
                text: 'Set Stream',
                onclick: function () {
                    chart.setOption({
                        series: [{
                            large: false,
                            progressive: 2000
                        }]
                    })
                }

            }])
        });
    })
</script>


<div class="chart" id="lines-clip"></div>
<script>
    require([
        'echarts'
    ], function (echarts) {

        var lineData = []

        function getColor() {
            //定义字符串变量colorValue存放可以构成十六进制颜色值的值
            var colorValue = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f";
            //以","为分隔符，将colorValue字符串分割为字符数组["0","1",...,"f"]
            var colorArray = colorValue.split(",");
            var color = "#";//定义一个存放十六进制颜色值的字符串变量，先将#存放进去
            //使用for循环语句生成剩余的六位十六进制值
            for (var i = 0; i < 6; i++) {
                //colorArray[Math.floor(Math.random()*16)]随机取出
                // 由16个元素组成的colorArray的某一个值，然后将其加在color中，
                //字符串相加后，得出的仍是字符串
                color += colorArray[Math.floor(Math.random() * 16)];
            }
            return color;
        }

        for (var i = 0; i < 20; ++i) {
            var x = Math.floor(Math.random() * 600 + 50)
            var y = Math.floor(Math.random() * 600 + 50)
            var xSign = Math.floor(Math.random() * 2 + 1)
            var ySign = Math.floor(Math.random() * 2 + 1)
            //负数
            if (xSign === 1) {
                x *= -1;
            }
            if (ySign === 1) {
                y *= -1;
            }

            var obj = {
                coords: [
                    [0, 0],
                    [x, y]
                ],
                label: {
                    show: false
                },
                lineStyle: {
                    normal: {
                        color: getColor(),
                        width: 1
                    }
                }
            };
            lineData.push(obj);
        }

        option = {
            animation: false,
            xAxis: {
                type: 'value',
                min: -1000,
                max: 1000,
                splitLine: {
                    lineStyle: {
                        width: 1
                    }
                }
            },
            yAxis: {
                type: 'value',
                min: -1000,
                max: 1000,
                splitLine: {
                    lineStyle: {
                        width: 1
                    }
                }
            },
            dataZoom: [{
                type: 'inside',
                xAxisIndex: 0,
                filterMode: 'filter',
                start: 30,
                end: 70
            },
                {
                    type: 'inside',
                    yAxisIndex: 0,
                    filterMode: 'weakFilter',
                    start: 30,
                    end: 70
                }
            ],
            series: [{
                type: 'lines',
                name: '网络拓扑图',
                coordinateSystem: 'cartesian2d',
                lineStyle: {
                    normal: {
                        color: '#F00',
                        width: 1
                    }
                },
                label: {
                    fontSize: 15
                },
                symbol: ['none', 'arrow'],
                // 数据
                data: lineData
            }]
        };

        var chart = testHelper.create(echarts, 'lines-clip', {
            title: 'Lines Clip,(case from #10748). Should not overflow after zoomed in',
            option: option,
            height: 400,
            buttons: makeToggleChartButtons(function (clip) {
                chart.setOption({
                    series: [{
                        clip: clip,
                        data: lineData
                    }]
                })
            })
        });
    })
</script>


<div class="chart" id="line-dataZoom-time"></div>
<script>
    require([
        'echarts'
    ], function (echarts) {

        var base = +new Date(2016, 9, 3);
        var oneDay = 24 * 3600 * 1000;
        var valueBase = Math.random() * 300;
        var valueBase2 = Math.random() * 50;
        var data = [];
        var data2 = [];

        for (var i = 1; i < 10; i++) {
            var now = new Date(base += oneDay);
            var dayStr = [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('-');

            valueBase = Math.round((Math.random() - 0.5) * 20 + valueBase);
            valueBase <= 0 && (valueBase = Math.random() * 300);
            data.push([dayStr, valueBase]);

            valueBase2 = Math.round((Math.random() - 0.5) * 20 + valueBase2);
            valueBase2 <= 0 && (valueBase2 = Math.random() * 50);
            data2.push([dayStr, valueBase2]);
        }

        option = {
            animation: false,
            tooltip: {
                triggerOn: 'none',
                position: function (pt) {
                    return [pt[0], 130];
                }
            },
            toolbox: {
                left: 'center',
                itemSize: 25,
                top: 55,
                feature: {
                    dataZoom: {
                        // Not filter the data.
                        // filterMode: 'none',
                        yAxisIndex: 'none'
                    },
                    restore: {}
                }
            },
            xAxis: {
                type: 'time',
                splitLine: {
                    show: false
                }
            },
            yAxis: {
                type: 'value',
                axisTick: {
                    inside: true
                },
                splitLine: {
                    show: false
                },
                axisLabel: {
                    inside: true,
                    formatter: '{value}\n'
                },
                z: 10
            },
            grid: {
                top: 110,
                left: 15,
                right: 15,
                height: 160
            },
            dataZoom: [{
                type: 'inside',
                filterMode: 'none',
                throttle: 50
            }],
            series: [
                {
                    name: '模拟数据',
                    type: 'line',
                    smooth: true,
                    symbol: 'circle',
                    symbolSize: 5,
                    sampling: 'average',
                    itemStyle: {
                        normal: {
                            color: '#8ec6ad'
                        }
                    },
                    stack: 'a',
                    areaStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#8ec6ad'
                            }, {
                                offset: 1,
                                color: '#ffe'
                            }])
                        }
                    },
                    data: data
                },
                {
                    name: '模拟数据',
                    type: 'line',
                    smooth: true,
                    stack: 'a',
                    symbol: 'circle',
                    symbolSize: 5,
                    sampling: 'average',
                    itemStyle: {
                        normal: {
                            color: '#d68262'
                        }
                    },
                    areaStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#d68262'
                            }, {
                                offset: 1,
                                color: '#ffe'
                            }])
                        }
                    },
                    data: data2
                }

            ]
        };

        function setFilterMode(mode) {
            chart.setOption({
                toolbox: {
                    feature: {
                        dataZoom: {
                            filterMode: mode
                        }
                    }
                }
            });
        }

        var chart = testHelper.create(echarts, 'line-dataZoom-time', {
            title: 'Line with dataZoom,(#10224). Should not be blank when selected a small area',
            option: option,
            height: 400,
            buttons: [{
                text: 'Set filter all',
                onclick: function () {
                    setFilterMode('filter');
                }
            }, {
                text: 'Set filter none',
                onclick: function () {
                    setFilterMode('none')
                }
            }]
        });
    })
</script>


<div class="chart" id="line-dataZoom-category"></div>
<script>
    require([
        'echarts'
    ], function (echarts) {
        option = {
            animation: false,
            toolbox: {
                left: 'center',
                itemSize: 25,
                top: 55,
                feature: {
                    dataZoom: {
                        // Not filter the data.
                        // filterMode: 'none',
                        yAxisIndex: 'none'
                    },
                    restore: {}
                }
            },
            grid: {
                top: 100
            },
            xAxis: [
                {
                    type: 'category',
                    boundaryGap: false,
                    data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
                }
            ],
            yAxis: [
                {
                    type: 'value'
                }
            ],
            series: [
                {
                    name: '邮件营销',
                    type: 'line',
                    stack: '总量',
                    areaStyle: {},
                    data: [120, 132, 101, 134, 90, 230, 210]
                },
                {
                    name: '联盟广告',
                    type: 'line',
                    stack: '总量',
                    areaStyle: {},
                    data: [220, 182, 191, 234, 290, 330, 310]
                },
                {
                    name: '视频广告',
                    type: 'line',
                    stack: '总量',
                    areaStyle: {},
                    data: [150, 232, 201, 154, 190, 330, 410]
                },
                {
                    name: '直接访问',
                    type: 'line',
                    stack: '总量',
                    areaStyle: {normal: {}},
                    data: [320, 332, 301, 334, 390, 330, 320]
                },
                {
                    name: '搜索引擎',
                    type: 'line',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'top'
                        }
                    },
                    areaStyle: {normal: {}},
                    data: [820, 932, 901, 934, 1290, 1330, 1320]
                }
            ]
        };

        function setFilterMode(mode) {
            chart.setOption({
                toolbox: {
                    feature: {
                        dataZoom: {
                            filterMode: mode
                        }
                    }
                }
            });
        }

        var chart = testHelper.create(echarts, 'line-dataZoom-category', {
            title: 'Line with dataZoom (category axis)',
            option: option,
            height: 400,
            buttons: [{
                text: 'Set filter all',
                onclick: function () {
                    setFilterMode('filter');
                }
            }, {
                text: 'Set filter none',
                onclick: function () {
                    setFilterMode('none')
                }
            }]
        });
    })
</script>


<div class="chart" id="bar-clip"></div>
<script>

    require([
        'echarts'
    ], function (echarts) {

        var xInversed = false;

        option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: {
                type: 'value',
                min: 200
            },
            yAxis: {
                type: 'category',
                data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
            },
            series: [
                {
                    name: '直接访问',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: [320, 302, 301, 334, 390, 330, 320]
                },
                {
                    name: '邮件营销',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: [120, 132, 101, 134, 90, 230, 210]
                },
                {
                    name: '联盟广告',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: [220, 182, 191, 234, 290, 330, 310]
                },
                {
                    name: '视频广告',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: [150, 212, 201, 154, 190, 330, 410]
                },
                {
                    name: '搜索引擎',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: [820, 832, 901, 934, 1290, 1330, 1320]
                }
            ]
        };

        var chart = testHelper.create(echarts, 'bar-clip', {
            title: 'Clip bar chart',
            option: option,
            height: 400,
            buttons: makeToggleChartButtons(function (clip) {
                chart.setOption({
                    series: [{
                        clip: clip
                    }]
                })
            }).concat([{
                text: 'Inverse X',
                onclick: function () {
                    xInversed = !xInversed;
                    chart.setOption({
                        xAxis: {
                            inverse: xInversed
                        }
                    });
                }
            }])
        });
    });
</script>


<div class="chart" id="bar-large-clip"></div>
<script>
    require([
        'echarts'/*, 'map/js/china' */
    ], function (echarts) {

        var xAxisData = [];
        var data1 = [];
        var data2 = [];
        var data3 = [];
        var data4 = [];
        for (var i = 0; i < 1000; i++) {
            xAxisData.push('类目' + i);
            data1.push((Math.random() * 5).toFixed(2));
            data2.push(Math.random().toFixed(2));
            data3.push((Math.random() + 0.5).toFixed(2));
            data4.push((Math.random() + 0.3).toFixed(2));
        }
        var isLarge = true;
        var option = {
            xAxis: {
                data: xAxisData,
                silent: false,
                splitLine: {
                    show: false
                },
                splitArea: {
                    show: false
                }
            },
            yAxis: {
                min: 1,
                max: 4,
                splitArea: {
                    show: false
                }
            },
            series: [{
                name: 'bar',
                type: 'bar',
                stack: 'one',
                data: data1,
                large: true
            }, {
                show: false,
                name: 'bar2',
                type: 'bar',
                stack: 'one',
                data: data2,
                large: true
            }, {
                name: 'bar3',
                type: 'bar',
                stack: 'two',
                data: data3,
                large: true
            }, {
                name: 'bar4',
                type: 'bar',
                stack: 'two',
                data: data4,
                large: true
            }]
        }

        function setLarge(large) {
            chart.setOption({
                series: [{
                    large: large
                }, {
                    large: large
                }, {
                    large: large
                }, {
                    large: large
                }]
            })
        }

        var chart = testHelper.create(echarts, 'bar-large-clip', {
            option: option,
            title: 'Bar clip with large mode',
            buttons: makeToggleChartButtons(function (clip) {
                chart.setOption({
                    series: [{
                        clip: clip
                    }, {
                        clip: clip
                    }, {
                        clip: clip
                    }, {
                        clip: clip
                    }]
                })
            }).concat([{
                text: 'Set large',
                onclick: function () {
                    setLarge(true);
                }
            }, {
                text: 'Set normal',
                onclick: function () {
                    setLarge(false);
                }
            }])
        });
    });
</script>

<div class="chart" id="custom-clip"></div>
<script>
    require([
        'echarts'
    ], function (echarts) {

        var data = [];
        var dataCount = 20;
        for (var i = 0; i < dataCount; i++) {
            var val = Math.random() * 1000;
            data.push([
                echarts.number.round(Math.random() * 100),
                echarts.number.round(Math.random() * 400)
            ]);
        }

        function renderItem(params, api) {
            if (params.context.rendered) {
                return;
            }
            params.context.rendered = true;

            var points = [];
            for (var i = 0; i < data.length; i++) {
                points.push(api.coord(data[i]));
            }
            var color = api.visual('color');

            return {
                type: 'polygon',
                shape: {
                    points: points
                },
                style: api.style({
                    fill: color,
                    stroke: echarts.color.lift(color)
                })
            };
        }

        option = {
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data: ['bar', 'error']
            },
            dataZoom: [{
                type: 'slider',
                filterMode: 'none',
                end: 40
            }, {
                type: 'inside',
                filterMode: 'none'
            }],
            xAxis: {},
            yAxis: {},
            series: [{
                type: 'custom',
                renderItem: renderItem,
                data: data,
                clip: true
            }]
        };

        var chart = testHelper.create(echarts, 'custom-clip', {
            title: 'Clip custon series',
            option: option,
            height: 400,
            buttons: makeToggleChartButtons(function (clip) {
                chart.setOption({
                    series: [{
                        clip: clip
                    }]
                })
            })
        });
    });
</script>


<div class="chart" id="candlestick-clip"></div>
<script>
    require([
        'echarts'
    ], function (echarts) {
        var upColor = '#ec0000';
        var upBorderColor = '#8A0000';
        var downColor = '#00da3c';
        var downBorderColor = '#008F28';

        // 数据意义：开盘(open)，收盘(close)，最低(lowest)，最高(highest)
        var data0 = splitData([
            ['2013/1/24', 2320.26, 2320.26, 2287.3, 2362.94],
            ['2013/1/25', 2300, 2291.3, 2288.26, 2308.38],
            ['2013/1/28', 2295.35, 2346.5, 2295.35, 2346.92],
            ['2013/1/29', 2347.22, 2358.98, 2337.35, 2363.8],
            ['2013/1/30', 2360.75, 2382.48, 2347.89, 2383.76],
            ['2013/1/31', 2383.43, 2385.42, 2371.23, 2391.82],
            ['2013/2/1', 2377.41, 2419.02, 2369.57, 2421.15],
            ['2013/2/4', 2425.92, 2428.15, 2417.58, 2440.38],
            ['2013/2/5', 2411, 2433.13, 2403.3, 2437.42],
            ['2013/2/6', 2432.68, 2434.48, 2427.7, 2441.73],
            ['2013/2/7', 2430.69, 2418.53, 2394.22, 2433.89],
            ['2013/2/8', 2416.62, 2432.4, 2414.4, 2443.03],
            ['2013/2/18', 2441.91, 2421.56, 2415.43, 2444.8],
            ['2013/2/19', 2420.26, 2382.91, 2373.53, 2427.07],
            ['2013/2/20', 2383.49, 2397.18, 2370.61, 2397.94],
            ['2013/2/21', 2378.82, 2325.95, 2309.17, 2378.82],
            ['2013/2/22', 2322.94, 2314.16, 2308.76, 2330.88],
            ['2013/2/25', 2320.62, 2325.82, 2315.01, 2338.78],
            ['2013/2/26', 2313.74, 2293.34, 2289.89, 2340.71],
            ['2013/2/27', 2297.77, 2313.22, 2292.03, 2324.63],
            ['2013/2/28', 2322.32, 2365.59, 2308.92, 2366.16],
            ['2013/3/1', 2364.54, 2359.51, 2330.86, 2369.65],
            ['2013/3/4', 2332.08, 2273.4, 2259.25, 2333.54],
            ['2013/3/5', 2274.81, 2326.31, 2270.1, 2328.14],
            ['2013/3/6', 2333.61, 2347.18, 2321.6, 2351.44],
            ['2013/3/7', 2340.44, 2324.29, 2304.27, 2352.02],
            ['2013/3/8', 2326.42, 2318.61, 2314.59, 2333.67],
            ['2013/3/11', 2314.68, 2310.59, 2296.58, 2320.96],
            ['2013/3/12', 2309.16, 2286.6, 2264.83, 2333.29],
            ['2013/3/13', 2282.17, 2263.97, 2253.25, 2286.33],
            ['2013/3/14', 2255.77, 2270.28, 2253.31, 2276.22],
            ['2013/3/15', 2269.31, 2278.4, 2250, 2312.08],
            ['2013/3/18', 2267.29, 2240.02, 2239.21, 2276.05],
            ['2013/3/19', 2244.26, 2257.43, 2232.02, 2261.31],
            ['2013/3/20', 2257.74, 2317.37, 2257.42, 2317.86],
            ['2013/3/21', 2318.21, 2324.24, 2311.6, 2330.81],
            ['2013/3/22', 2321.4, 2328.28, 2314.97, 2332],
            ['2013/3/25', 2334.74, 2326.72, 2319.91, 2344.89],
            ['2013/3/26', 2318.58, 2297.67, 2281.12, 2319.99],
            ['2013/3/27', 2299.38, 2301.26, 2289, 2323.48],
            ['2013/3/28', 2273.55, 2236.3, 2232.91, 2273.55],
            ['2013/3/29', 2238.49, 2236.62, 2228.81, 2246.87],
            ['2013/4/1', 2229.46, 2234.4, 2227.31, 2243.95],
            ['2013/4/2', 2234.9, 2227.74, 2220.44, 2253.42],
            ['2013/4/3', 2232.69, 2225.29, 2217.25, 2241.34],
            ['2013/4/8', 2196.24, 2211.59, 2180.67, 2212.59],
            ['2013/4/9', 2215.47, 2225.77, 2215.47, 2234.73],
            ['2013/4/10', 2224.93, 2226.13, 2212.56, 2233.04],
            ['2013/4/11', 2236.98, 2219.55, 2217.26, 2242.48],
            ['2013/4/12', 2218.09, 2206.78, 2204.44, 2226.26],
            ['2013/4/15', 2199.91, 2181.94, 2177.39, 2204.99],
            ['2013/4/16', 2169.63, 2194.85, 2165.78, 2196.43],
            ['2013/4/17', 2195.03, 2193.8, 2178.47, 2197.51],
            ['2013/4/18', 2181.82, 2197.6, 2175.44, 2206.03],
            ['2013/4/19', 2201.12, 2244.64, 2200.58, 2250.11],
            ['2013/4/22', 2236.4, 2242.17, 2232.26, 2245.12],
            ['2013/4/23', 2242.62, 2184.54, 2182.81, 2242.62],
            ['2013/4/24', 2187.35, 2218.32, 2184.11, 2226.12],
            ['2013/4/25', 2213.19, 2199.31, 2191.85, 2224.63],
            ['2013/4/26', 2203.89, 2177.91, 2173.86, 2210.58],
            ['2013/5/2', 2170.78, 2174.12, 2161.14, 2179.65],
            ['2013/5/3', 2179.05, 2205.5, 2179.05, 2222.81],
            ['2013/5/6', 2212.5, 2231.17, 2212.5, 2236.07],
            ['2013/5/7', 2227.86, 2235.57, 2219.44, 2240.26],
            ['2013/5/8', 2242.39, 2246.3, 2235.42, 2255.21],
            ['2013/5/9', 2246.96, 2232.97, 2221.38, 2247.86],
            ['2013/5/10', 2228.82, 2246.83, 2225.81, 2247.67],
            ['2013/5/13', 2247.68, 2241.92, 2231.36, 2250.85],
            ['2013/5/14', 2238.9, 2217.01, 2205.87, 2239.93],
            ['2013/5/15', 2217.09, 2224.8, 2213.58, 2225.19],
            ['2013/5/16', 2221.34, 2251.81, 2210.77, 2252.87],
            ['2013/5/17', 2249.81, 2282.87, 2248.41, 2288.09],
            ['2013/5/20', 2286.33, 2299.99, 2281.9, 2309.39],
            ['2013/5/21', 2297.11, 2305.11, 2290.12, 2305.3],
            ['2013/5/22', 2303.75, 2302.4, 2292.43, 2314.18],
            ['2013/5/23', 2293.81, 2275.67, 2274.1, 2304.95],
            ['2013/5/24', 2281.45, 2288.53, 2270.25, 2292.59],
            ['2013/5/27', 2286.66, 2293.08, 2283.94, 2301.7],
            ['2013/5/28', 2293.4, 2321.32, 2281.47, 2322.1],
            ['2013/5/29', 2323.54, 2324.02, 2321.17, 2334.33],
            ['2013/5/30', 2316.25, 2317.75, 2310.49, 2325.72],
            ['2013/5/31', 2320.74, 2300.59, 2299.37, 2325.53],
            ['2013/6/3', 2300.21, 2299.25, 2294.11, 2313.43],
            ['2013/6/4', 2297.1, 2272.42, 2264.76, 2297.1],
            ['2013/6/5', 2270.71, 2270.93, 2260.87, 2276.86],
            ['2013/6/6', 2264.43, 2242.11, 2240.07, 2266.69],
            ['2013/6/7', 2242.26, 2210.9, 2205.07, 2250.63],
            ['2013/6/13', 2190.1, 2148.35, 2126.22, 2190.1]
        ]);

        function splitData(rawData) {
            var categoryData = [];
            var values = []
            for (var i = 0; i < rawData.length; i++) {
                categoryData.push(rawData[i].splice(0, 1)[0]);
                values.push(rawData[i])
            }
            return {
                categoryData: categoryData,
                values: values
            };
        }

        function calculateMA(dayCount) {
            var result = [];
            for (var i = 0, len = data0.values.length; i < len; i++) {
                if (i < dayCount) {
                    result.push('-');
                    continue;
                }
                var sum = 0;
                for (var j = 0; j < dayCount; j++) {
                    sum += data0.values[i - j][1];
                }
                result.push(sum / dayCount);
            }
            return result;
        }


        option = {
            title: {
                text: '上证指数',
                left: 0
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross'
                }
            },
            legend: {
                data: ['日K', 'MA5', 'MA10', 'MA20', 'MA30']
            },
            grid: {
                left: '10%',
                right: '10%',
                bottom: '15%'
            },
            xAxis: {
                type: 'category',
                data: data0.categoryData,
                scale: true,
                boundaryGap: false,
                axisLine: {onZero: false},
                splitLine: {show: false},
                splitNumber: 20,
                min: 'dataMin',
                max: 'dataMax'
            },
            yAxis: {
                scale: true,
                splitArea: {
                    show: true
                }
            },
            dataZoom: [
                {
                    type: 'inside',
                    filterMode: 'none',
                    start: 50,
                    end: 100
                },
            ],
            series: [
                {
                    name: '日K',
                    type: 'candlestick',
                    data: data0.values,
                    itemStyle: {
                        normal: {
                            color: upColor,
                            color0: downColor,
                            borderColor: upBorderColor,
                            borderColor0: downBorderColor
                        }
                    }
                },
                {
                    name: 'MA5',
                    type: 'line',
                    data: calculateMA(5),
                    smooth: true,
                    lineStyle: {
                        normal: {opacity: 0.5}
                    }
                },
                {
                    name: 'MA10',
                    type: 'line',
                    data: calculateMA(10),
                    smooth: true,
                    lineStyle: {
                        normal: {opacity: 0.5}
                    }
                },
                {
                    name: 'MA20',
                    type: 'line',
                    data: calculateMA(20),
                    smooth: true,
                    lineStyle: {
                        normal: {opacity: 0.5}
                    }
                },
                {
                    name: 'MA30',
                    type: 'line',
                    data: calculateMA(30),
                    smooth: true,
                    lineStyle: {
                        normal: {opacity: 0.5}
                    }
                },

            ]
        };

        var chart = testHelper.create(echarts, 'candlestick-clip', {
            title: [
                'Clip candlestick',
                'Case from #11010'
            ],
            option: option,
            height: 400,
            buttons: makeToggleChartButtons(function (clip) {
                chart.setOption({
                    series: [{
                        clip: clip
                    }]
                })
            })
        });
    });
</script>


<div class="chart" id="candlestick-large-clip"></div>
<script>
    require([
        'echarts',
        'data/stock-DJI.json'
    ], function (echarts, rawData) {
        var option = {
            dataset: {
                source: rawData
            },
            backgroundColor: '#eee',
            legend: {
                left: 0,
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross'
                },
                backgroundColor: 'rgba(245, 245, 245, 0.8)',
                borderWidth: 1,
                borderColor: '#ccc',
                padding: 10,
                textStyle: {
                    color: '#000'
                },
                position: function (pos, params, el, elRect, size) {
                    var obj = {top: 10};
                    obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 30;
                    return obj;
                }
            },
            axisPointer: {
                link: {xAxisIndex: 'all'},
                label: {
                    backgroundColor: '#777'
                }
            },
            toolbox: {
                feature: {
                    dataZoom: {
                        yAxisIndex: false
                    },
                    brush: {
                        type: ['polygon', 'rect', 'lineX', 'lineY', 'keep', 'clear']
                    }
                }
            },
            brush: {
                xAxisIndex: 'all',
                brushLink: 'all',
                outOfBrush: {
                    colorAlpha: 0.1
                }
            },
            grid: [
                {
                    left: '10%',
                    right: '10%',
                    height: 300
                }
            ],
            xAxis: [
                {
                    type: 'category',
                    scale: true,
                    boundaryGap: false,
                    axisLine: {onZero: false},
                    splitLine: {show: false},
                    splitNumber: 20,
                    min: 'dataMin',
                    max: 'dataMax'
                }
            ],
            yAxis: [
                {
                    scale: true
                }
            ],
            dataZoom: [
                {
                    show: true,
                    type: 'slider',
                    filterMode: 'none',
                    bottom: 10,
                    start: 50
                }
            ],
            animation: false,
            series: [
                {
                    name: 'Dow-Jones index',
                    type: 'candlestick',
                    large: true,
                    encode: {
                        x: 0,
                        y: [1, 2, 3, 4]
                    },
                    itemStyle: {
                        normal: {
                            borderColor: null,
                            borderColor0: null
                        }
                    }
                }
            ]
        };

        var chart = testHelper.create(echarts, 'candlestick-large-clip', {
            title: [
                'Clip large candlestick'
            ],
            option: option,
            height: 400,
            buttons: makeToggleChartButtons(function (clip) {
                chart.setOption({
                    series: [{
                        clip: clip
                    }]
                })
            })
        });
    });
</script>


<div class="chart" id="line-highlight-point"></div>
<script>
    require([
        'echarts'
    ], function (echarts) {
        var option = {
            grid: {
                top: 130,
                bottom: 80
            },
            dataZoom: [{
                type: 'slider',
                show: true
            },
                {
                    type: 'inside'
                }
            ],
            xAxis: {
                type: 'category',
                name: 'x',
                splitLine: {
                    show: false
                },
                data: ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
                axisPointer: {
                    show: 'true'
                },
            },
            yAxis: {
                name: 'y',
                max: 20
            },
            tooltip: {
                trigger: 'item'
            },
            series: [{
                name: 'B',
                type: 'line',
                clip: true,
                data: [1, 2, 4, 8, 16, 32, 64, 128, 256]
            }]
        };
        var chart = testHelper.create(echarts, 'line-highlight-point', {
            title: 'Line Clip on emphasis',
            option: option,
            height: 400,
            buttons: makeToggleChartButtons(function (clip) {
                chart.setOption({
                    series: [{
                        clip: clip
                    }]
                })
            })
        });
    })
</script>

</body>
</html>
